<?php 
$listmenu   = array();

$listmenu[] = array(
    'label'         => 'Users',
    'child'         => array(
        array(
            'controller'    => 'Users',
            'action'        => 'admin_index',
            'label'         => 'Users',
            'othercontroller'=> array(
                'user_profiles'
            ),
            'otheraction'   => array(
                'change_password',
                'add'
            )
        ),
        array(
            'controller'    => 'UserLogins',
            'action'        => 'admin_index',
            'label'         => 'User Logins'
        ),
        array(
            'controller'    => 'user_comments',
            'action'        => 'admin_index',
            'label'         => 'User Comments'
        ),
    )
);

$listmenu[] = array(
    'controller'    => 'Companies',
    'action'        => '',
    'label'         => 'Companies',
    'othercontroller' => array(
        'company_addresses'
    )
);

if($html->isWalletEnabled('is_enable_for_add_to_wallet')){
    if((Configure::read('company.is_user_can_withdraw_amount')) || (Configure::read('user.is_user_can_with_draw_amount'))){
        $listmenu[] = array(
            'controller'    => 'UserCashWithdrawals',
            'action'        => '',
            'label'         => 'Withdraw Fund Requests'
        );
    }
}

$listmenu[] = array(
    'label'         => 'Deals',
    'child'         => array(
        array(
            'controller'    => 'Deals',
            'action'        => 'admin_index',
            'label'         => 'Deals',
            'otheraction'   => array(
                'edit'
            )
        ),
        array(
            'controller'    => 'Deals',
            'action'        => 'add',
            'label'         => 'Add Deal'
        ),
        array(
            'controller'    => 'DealUsers',
            'action'        => '',
            'label'         => 'Deal Coupons'
        ),
        array(
            'controller'    => 'DealUserVouchers',
            'action'        => '',
            'label'         => 'Deal Backfill'
        ),
        
    )
);


$listmenu[] = array(
    'controller'    => 'GiftUsers',
    'action'        => '',
    'label'         => 'Gift Cards'
);


$listmenu[] = array(
    'label'         => 'Subscriptions',
    'child'         => array(
        array(
            'controller'    => 'Subscriptions',
            'action'        => 'admin_index',
            'label'         => 'Subscriptions'
        ),
        array(
            'controller'    => 'Subscriptions',
            'action'        => 'admin_subscription_customise',
            'label'         => 'Subscriptions Customise'
        )
    )
);


$listmenu[] = array(
    'label'         => 'Suggestions',
    'child'         => array(
        array(
            'controller'    => 'CitySuggestions',
            'action'        => '',
            'label'         => 'Cities'
        ),
        array(
            'controller'    => 'BusinessSuggestions',
            'action'        => '',
            'label'         => 'Business'
        )
    )
);

$listmenu[] = array(
    'label'         => 'Topics',
    'child'         => array(
        array(
            'controller'    => 'Topics',
            'action'        => '',
            'label'         => 'Topics'
        ),
        array(
            'controller'    => 'TopicDiscussions',
            'action'        => '',
            'label'         => 'Topic Discussions'
        )
    )
);

$listmenu[] = array(
    'label'         => 'Payment Gateways',
    'child'         => array(
        array(
            'controller'    => 'PaymentGateways',
            'action'        => '',
            'label'         => 'Payment Gateways'
        ),
        array(
            'controller'    => 'Transactions',
            'action'        => '',
            'label'         => 'Transactions'
        )
    )
);

if(Configure::read('charity.is_enabled') == 1){
    $listmenu[] = array(
        'label'         => 'Charity',
        'child'         => array(
            array(
                'controller'    => 'Charities',
                'action'        => '',
                'label'         => 'Charities'
            )
        )
    );
}

$listmenu[] = array(
    'label'         => 'Advertiser',
    'child'         => array(
        array(
            'controller'    => 'Advertisers',
            'action'        => '',
            'label'         => 'Advertisers'
        )
    )
);

if(Configure::read('charity.is_enabled') == 1){
    $listmenu[] = array(
        'label'         => 'Affiliates',
        'child'         => array(
            array(
                'controller'    => 'Affiliates',
                'action'        => '',
                'label'         => 'Affiliates'
            )
        )
    );
}


$listmenu[] = array(
    'label'         => 'Masters',
    'child'         => array(
        array(
            'controller'    => 'Settings',
            'action'        => '',
            'label'         => 'Settings'
        ),
        array(
            'controller'    => 'Currencies',
            'action'        => '',
            'label'         => 'Currencies'
        ),
        array(
            'controller'    => 'EmailTemplates',
            'action'        => '',
            'label'         => 'Email Templates'
        ),
        array(
            'controller'    => 'Pages',
            'action'        => '',
            'label'         => 'Manage Static Pages'
        ),
        array(
            'controller'    => 'TransactionTypes',
            'action'        => '',
            'label'         => 'Transaction Types'
        ),
        array(
            'controller'    => 'Translations',
            'action'        => '',
            'label'         => 'Translations'
        ),
        array(
            'controller'    => 'Languages',
            'action'        => '',
            'label'         => 'Languages'
        ),
        array(
            'controller'    => 'BannedIps',
            'action'        => '',
            'label'         => 'Banned IPs'
        ),
        array(
            'controller'    => 'Cities',
            'action'        => '',
            'label'         => 'Cities'
        ),
        array(
            'controller'    => 'States',
            'action'        => '',
            'label'         => 'States'
        ),
        array(
            'controller'    => 'Countries',
            'action'        => '',
            'label'         => 'Countries'
        ),
        array(
            'controller'    => 'UserEducations',
            'action'        => '',
            'label'         => 'Educations'
        ),
        array(
            'controller'    => 'UserEmployments',
            'action'        => '',
            'label'         => 'Employments'
        ),
        array(
            'controller'    => 'UserIncomeRanges',
            'action'        => '',
            'label'         => 'Income Ranges'
        ),
        array(
            'controller'    => 'UserRelationships',
            'action'        => '',
            'label'         => 'Relationships'
        ),
        array(
            'controller'    => 'MailChimpLists',
            'action'        => '',
            'label'         => 'Mail Chimp Lists'
        ),
        array(
            'controller'    => 'Genders',
            'action'        => '',
            'label'         => 'Genders'
        ),
        array(
            'controller'    => 'PrivacyTypes',
            'action'        => '',
            'label'         => 'Privacy Types'
        ),
        array(
            'controller'    => 'CharityCategories',
            'action'        => '',
            'label'         => 'Charity Categories'
        ),
    )
);


?>

<h5 class="hidden-info"><?php echo __l('Admin side links'); ?></h5>
<ul class="admin-links">
	<?php $class = ($this->params['controller'] == 'users' && $this->params['action'] == 'admin_stats') ? ' class="active"' : null; ?>
	<li <?php echo $class;?>><?php echo $html->link(__l('Site Stats'), array('controller' => 'users', 'action' => 'stats'),array('title' => __l('Site Stats'))); ?></li>
	    
    <?php
    //build menu
    
    foreach($listmenu as $i => $menu)
    {
        if(isset($menu['child']))
        {
            
            $childtext  = '';
            foreach($menu['child']  as $child)
            {
                $access = $controller->getPermission($child['controller'],$child['action']);
                if($access==false)
                {
                    continue;
                }
                $childtext.= $html->displayli($child);
            }
            if(empty($childtext))continue;
            echo '<li class="no-bor">';
            echo '<h4>'.__l($menu['label']).'</h4>';
            echo '<ul class="admin-sub-links">';
            echo $childtext;
            echo '</ul>';
            echo '</li>';
        }else
        {
            $access = $controller->getPermission($menu['controller'],$menu['action']);
            if($access==false)
            {
                continue;
            }
            echo $html->displayli($menu);
        }
    }
    ?>    
  
    
    <?php if($auth->user('group_id')==ConstUserTypes::Admin):?>
    <li class="no-bor">
		<h4><?php echo __l('Diagnostics (Developer purpose only)'); ?></h4>
		<ul class="admin-sub-links">
           <?php $class = ($this->params['controller'] == 'paypal_transaction_logs' && $this->params['named']['type'] == 'normal') ? ' class="active"' : null; ?>
			<li <?php echo $class;?>><?php echo $html->link(__l('Payment Transaction Log'), array('controller' => 'paypal_transaction_logs', 'action' => 'index', 'type' => 'normal'),array('title' => __l('Payment Transaction Log'))); ?></li>
			<?php $class = ($this->params['controller'] == 'paypal_transaction_logs' && $this->params['named']['type'] == 'mass') ? ' class="active"' : null; ?>
			<li <?php echo $class;?>><?php echo $html->link(__l('Mass Payment Transaction Log'), array('controller' => 'paypal_transaction_logs', 'action' => 'index', 'type' => 'mass'),array('title' => __l('Mass Payment Transaction Log'))); ?></li>
			<?php $class = ($this->params['controller'] == 'paypal_docapture_logs') ? ' class="active"' : null; ?>
			<li <?php echo $class;?>><?php echo $html->link(__l('Paypal Docapture Log'), array('controller' => 'paypal_docapture_logs', 'action' => 'index'),array('title' => __l('Paypal Docapture Log'))); ?></li>
			<?php $class = ($this->params['controller'] == 'authorizenet_docapture_logs') ? ' class="active"' : null; ?>
			<li <?php echo $class;?>><?php echo $html->link(__l('Authorizenet Docapture Log'), array('controller' => 'authorizenet_docapture_logs', 'action' => 'index'),array('title' => __l('Authorizenet Docapture Log'))); ?></li>
            	<?php $class = ($this->params['controller'] == 'authorizenet_docapture_logs' && $this->params['action']=='clear_cache') ? ' class="active"' : null; ?>
			<li <?php echo $class;?>><?php echo $html->link(__l('Clear Cache'), array('controller' => 'authorizenet_docapture_logs', 'action' => 'clear_cache'),array('title' => __l('Clear cache'))); ?></li>
  			<?php $class = ($this->params['controller'] == 'users' && $this->params['action'] == 'admin_logs') ? ' class="active"' : null; ?>
			<li <?php echo $class;?>><?php echo $html->link(__l('Debug & Error Log'), array('controller' => 'users', 'action' => 'logs'),array('title' => __l('Debug & Error Log'))); ?></li>
		</ul>
	</li>
    <?php endif;?>    
</ul>

